package ll.sms.socket.service;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class ClientRun implements Runnable {
	@SuppressWarnings("unused")
	private Socket s;
	private DataInputStream dis = null;
	private DataOutputStream dos = null;
	boolean bConnect = false;

	public ClientRun(Socket s) {
		this.s = s;
		try {
			dis = new DataInputStream(s.getInputStream());
			dos = new DataOutputStream(s.getOutputStream());
			bConnect = true;
		} catch (IOException e) {

		}
	}

	public void send(String str) {
		try {
			dos.writeUTF(str);
		} catch (IOException e) {

		}
	}

	public String read() {
		try {
			return dis.readUTF();
		} catch (IOException e) {
			return "";
		}
	}

	public void run() {
		try {
			while (bConnect) {
				String str = read();
				send(str);
			}
		} catch (Exception e) {

		}
	}
}
